package com.tianyuan.dplrf.ui.adapter;

import android.content.Context;
import android.util.Log;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatImageView;

import com.hjq.base.BaseAdapter;
import com.tianyuan.dplrf.R;
import com.tianyuan.dplrf.app.AppAdapter;
import com.tianyuan.dplrf.ui.bean.NcjtBean;
import com.xuexiang.xutil.XUtil;
import com.xuexiang.xutil.display.DensityUtils;

public class NcjtFlAdapter extends AppAdapter<NcjtBean> {
    int withDim;

    public NcjtFlAdapter(@NonNull Context context) {
        super(context);
        withDim = DensityUtils.getScreenWidth()/3;
    }

    @NonNull
    @Override
    public BaseAdapter<?>.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder();
    }

    private final class ViewHolder extends BaseAdapter.ViewHolder{


        private AppCompatImageView img;
        private TextView tv;

        public ViewHolder() {
            super(R.layout.item_ncjt_fragment_fl);
            img = getItemView().findViewById(R.id.img);
            tv = getItemView().findViewById(R.id.tv);


        }

        @Override
        public void onBindView(int position) {
            img.setImageResource(getItem(position).getImgl());
            tv.setText(getItem(position).getDesc());
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(withDim/2,withDim/2);
            img.setLayoutParams(params);

        }

    }
}
